package com.dlnu.shoping.shopping.controller;

import com.baomidou.mybatisplus.extension.api.R;
import com.dlnu.shoping.shopping.common.Result;
import com.dlnu.shoping.shopping.service.ILoginService;
import com.dlnu.shoping.shopping.service.IProductService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/product")
public class productController {
    @Resource
    private IProductService productService;

    @RequestMapping("/searchById")
    public Result searchByProId(@RequestParam Integer proId) {
        return productService.searchByProId(proId);
    }

    @RequestMapping("/search")
    public Result search(@RequestParam(required = false) String name) {
        return productService.searchByName(name);
    }

    @RequestMapping("/queryByCategoryId")
    public Result queryByCategoryId(@RequestParam(required = false,defaultValue = "1") Integer pageNo,
                                    @RequestParam(required = false,defaultValue = "10") Integer pageSize,
                                    @RequestParam Integer categoryId) {
        return productService.queryByCategoryId(pageNo,pageSize,categoryId);
    }
}
